﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cloud.Model;
using Cloud.BLL;

    

public partial class Three_Managerment_P0401_Edit_kw : System.Web.UI.Page
{
     protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {


       

                 Problem activity = ProblemManager.FindById(Convert.ToInt32(Request.QueryString["id"]));
                 this.biaohao.Value = activity.Appealid.ToString();
                 this.name.Value = activity.Appeal_name.ToString();
                 this.tel.Value = activity.Appeal_tel.ToString();
                 this.title.Value = activity.Title.ToString();
                 this.con.Value = activity.Context.ToString();


                 this.guishu.DataSource = AscriptionManager.FindAll();
                 this.guishu.DataTextField = "name";
                 this.guishu.DataValueField = "id";
                 this.guishu.DataBind();
                 this.guishu.SelectedValue = activity.Ascription_id.ToString();
                 
                 this.dl_drop.DataSource = Classification_Appeal1Manager.FindAll();
                 this.dl_drop.DataTextField = "name";
                 this.dl_drop.DataValueField = "id";
                 this.dl_drop.DataBind();
                 this.dl_drop.SelectedValue = activity.Appeal_type_id.ToString();
                 this.xl_drop.DataSource = Classification_Appeal2Manager.FindBySort(Convert.ToInt32(this.dl_drop.SelectedItem.Value));
                 this.xl_drop.DataTextField = "name";
                 this.xl_drop.DataValueField = "id";
                 this.xl_drop.DataBind();
                 this.xl_drop.SelectedValue = activity.Xialei.ToString();
            }
        }
        catch (Exception ex)
        {

            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void Unnamed_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            Problem activity = ProblemManager.FindById(Convert.ToInt32(Request.QueryString["id"]));
           

            activity.Appeal_name = this.name.Value;
            activity.Appeal_tel = this.tel.Value;
            activity.Ascription_id = Convert.ToInt32(guishu.SelectedItem.Value);

            activity.Xialei = Convert.ToInt32(xl_drop.SelectedItem.Value);
            activity.Appeal_type_id = Convert.ToInt32(dl_drop.SelectedItem.Value);
            activity.Context = con.Value;
      
          
            activity.Title = this.title.Value;
          


            if (ProblemManager.Update(activity) > 0)
            {

                //Problem_historic2 his = new Problem_historic2();
                //his.Blyj = "";
                //his.Title = "录入 ";
                //his.Bm2 = "";
                //his.Evente = 0;
                //his.Idopen = this.biaohao.Value;

                //his.Bm1 = ((USER_INFO)Session["users"]).DEPARTMENT;
                //his.Item1 = 0;
                //his.Item2 = "";
                //his.Item3 = "";
                //his.Name = ((USER_INFO)Session["users"]).USER_NAME;
                //his.Times = DateTime.Now;
                //his.Timese = new DateTime(1900, 01, 01, 00, 00, 00);


                //Problem_historic2Manager.Save(his);

                Response.Write("<script>alert('勘误成功');location.href='index.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('勘误失败');</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }

    protected void feilei_SelectedIndexChanged(object sender, EventArgs e)
    {

        try
        {
            this.xl_drop.DataSource = Classification_Appeal2Manager.FindBySort(Convert.ToInt32(this.dl_drop.SelectedItem.Value));
            this.xl_drop.DataTextField = "name";
            this.xl_drop.DataValueField = "id";
            this.xl_drop.DataBind();

        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }

    }
   
}